package edu.hunau.cxb19.oop.class07;

import org.junit.Test;

import edu.hunau.cxb19.oop.class07.hk.Poker;

/**
 *
 * @author hb
 *
 *         2020-03-03 14:47:08
 */
public class PokerTest {

	@Test
	public void init() {
		// 实例化一个梅花3
		Poker m3 = new Poker(2, 0);
		Poker m4 = new Poker(Poker.SUIT_MEIHUA, Poker.RANK_3);
		
		//判定两个对象是否相同
		System.out.println(m3==m4);//false
		System.out.println(m3.equals(m4));
		
		System.out.println(m3.toString());//toString方法从Object继承
		System.out.println(m4);//直接输出对象的引用时，默认调用toString方法
		 

	}

	public Poker[] initNewPorks() {
		Poker[] pokers = new Poker[54];
		int index = 0;
		// 52张扑克牌
		for (int suit = 0; suit <= Poker.SUIT_FANGKU; suit++) {
			for (int rank = 0; rank <= Poker.RANK_2; rank++) {
				pokers[index++] = new Poker(suit, rank);
			}
		}

		pokers[index++] = new Poker(Poker.SUIT_KING, Poker.SMALL);
		pokers[index++] = new Poker(Poker.SUIT_KING, Poker.BIG);

		return pokers;

	}

	@Test
	public void showPokers() {
		Poker[] pokers = initNewPorks();
		for (int i = 0; i < pokers.length; i++) {
			System.out.print (pokers[i]+" ");
			if((i+1)%13==0) {
				System.out.println();
			}
			
		}
	}
}
